package com.ruoyi.property.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.property.domain.FeeReceiptManageInfo;
import com.ruoyi.property.service.IFeeReceiptManageInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补打收据Controller
 * 
 * @author sux
 * @date 2021-06-30
 */
@Controller
@RequestMapping("/property/feeReceiptManageInfo")
public class FeeReceiptManageInfoController extends BaseController
{
    private String prefix = "property/feeReceiptManageInfo";

    @Autowired
    private IFeeReceiptManageInfoService feeReceiptManageInfoService;

    @RequiresPermissions("property:feeReceiptManageInfo:view")
    @GetMapping()
    public String feeReceiptManageInfo()
    {
        return prefix + "/feeReceiptManageInfo";
    }

    /**
     * 查询补打收据列表
     */
    @RequiresPermissions("property:feeReceiptManageInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FeeReceiptManageInfo feeReceiptManageInfo)
    {
        startPage();
        List<FeeReceiptManageInfo> list = feeReceiptManageInfoService.selectFeeReceiptManageInfoList(feeReceiptManageInfo);
        return getDataTable(list);
    }

    /**
     * 导出补打收据列表
     */
    @RequiresPermissions("property:feeReceiptManageInfo:export")
    @Log(title = "补打收据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FeeReceiptManageInfo feeReceiptManageInfo)
    {
        List<FeeReceiptManageInfo> list = feeReceiptManageInfoService.selectFeeReceiptManageInfoList(feeReceiptManageInfo);
        ExcelUtil<FeeReceiptManageInfo> util = new ExcelUtil<FeeReceiptManageInfo>(FeeReceiptManageInfo.class);
        return util.exportExcel(list, "feeReceiptManageInfo");
    }

    /**
     * 新增补打收据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存补打收据
     */
    @RequiresPermissions("property:feeReceiptManageInfo:add")
    @Log(title = "补打收据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FeeReceiptManageInfo feeReceiptManageInfo)
    {
        return toAjax(feeReceiptManageInfoService.insertFeeReceiptManageInfo(feeReceiptManageInfo));
    }

    /**
     * 修改补打收据
     */
    @GetMapping("/edit/{receiptId}")
    public String edit(@PathVariable("receiptId") Long receiptId, ModelMap mmap)
    {
        FeeReceiptManageInfo feeReceiptManageInfo = feeReceiptManageInfoService.selectFeeReceiptManageInfoById(receiptId);
        mmap.put("feeReceiptManageInfo", feeReceiptManageInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存补打收据
     */
    @RequiresPermissions("property:feeReceiptManageInfo:edit")
    @Log(title = "补打收据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FeeReceiptManageInfo feeReceiptManageInfo)
    {
        return toAjax(feeReceiptManageInfoService.updateFeeReceiptManageInfo(feeReceiptManageInfo));
    }

    /**
     * 删除补打收据
     */
    @RequiresPermissions("property:feeReceiptManageInfo:remove")
    @Log(title = "补打收据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(feeReceiptManageInfoService.deleteFeeReceiptManageInfoByIds(ids));
    }
}
